<?php

use think\facade\Route;

$miss = function () {
    $arr = [
        'code' => -1,
        'msg' => '请输入正确的路由地址',
        'data' => []
    ];
    return json($arr);
};
// 主页路由
Route::miss($miss);
// 只需要验证token的放在一起
$func = function () {
    //订单
    Route::group('/api/order', function () {
        Route::get('', 'admin.Order/query');
    });
    //轮播图
    Route::group('/api/banner', function () {
        Route::get('', 'admin.Banner/query');
        Route::post('', 'admin.Banner/create');
        Route::put(':id', 'admin.Banner/update');
        Route::delete(':id', 'admin.Banner/remove');
        Route::put('/enable/:id', 'admin.Banner/enable');
        Route::put('/disable/:id', 'admin.Banner/disable');
    });
    //公告
    Route::group('/api/notice', function () {
        Route::get(':id', 'admin.Notice/detail');
        Route::put(':id', 'admin.Notice/update');
    });
    //门店
    Route::group('/api/store', function () {
        Route::get('', 'admin.Store/query');
        Route::post('', 'admin.Store/create');
        Route::put(':id', 'admin.Store/update');
        Route::delete(':id', 'admin.Store/remove');
    });
    //助教
    Route::group('/api/assistant', function () {
        Route::get('', 'admin.Assistant/query');
        Route::post('', 'admin.Assistant/create');
        Route::put(':id', 'admin.Assistant/update');
        Route::delete(':id', 'admin.Assistant/remove');
    });
    //后台登录用户
    Route::group('/api/user', function () {
        Route::get('detail', 'admin.User/detail');
    });
    //用户
    Route::group('/api/member', function () {
        //列表
        Route::get('', 'admin.Member/query');
        //开通助教
        Route::put(':id/openAssistant', 'admin.Member/openAssistant');
    });
    //包间
    Route::group('/api/room', function () {
        Route::get('', 'admin.Room/query');
        Route::post('', 'admin.Room/create');
        Route::put(':id', 'admin.Room/update');
        Route::delete(':id', 'admin.Room/remove');
    });
    //道具
    Route::group('/api/prop', function () {
        Route::get('', 'admin.Prop/query');
        Route::post('', 'admin.Prop/create');
        Route::put(':id', 'admin.Prop/update');
        Route::delete(':id', 'admin.Prop/remove');
        //赠送用户道具
        Route::post(':prop_id/giveProp', 'admin.PropMember/giveProp');
    });
    //等级管理
    Route::group('/api/grade', function () {
        Route::get('', 'admin.Grade/query');
        Route::post('', 'admin.Grade/create');
        Route::put(':id', 'admin.Grade/update');
        Route::delete(':id', 'admin.Grade/remove');
    });
    //游戏
    Route::group('/api/game', function () {
        Route::get('', 'admin.Game/query');
        Route::post('', 'admin.Game/create');
        Route::put(':id', 'admin.Game/update');
        Route::delete(':id', 'admin.Game/remove');
    });
    //头像框
    Route::group('/api/avatar_frame', function () {
        Route::get('', 'admin.AvatarFrame/query');
        Route::post('', 'admin.AvatarFrame/create');
        Route::put(':id', 'admin.AvatarFrame/update');
        Route::delete(':id', 'admin.AvatarFrame/remove');
    });
    //预约
    Route::group('/api/book', function () {
        Route::get('', 'admin.Book/query');
    });
    //报班
    Route::group('/api/duty', function () {
        Route::get('', 'admin.Duty/query');
        Route::put(':id/enable', 'admin.Duty/enable');
        Route::put(':id/disable', 'admin.Duty/disable');
    });
    //配置
    Route::group('/api/config', function () {
        Route::get('', 'admin.Config/detail');
        Route::put('', 'admin.Config/update');
    });
    //CP
    Route::group('/api/cp', function () {
        //列表
        Route::get('', 'admin.Cp/query');
        //启用
        Route::put(':id/enable', 'admin.Cp/enable');
        //禁用
        Route::put(':id/disable', 'admin.Cp/disable');
    });
};
Route::post('/api/user/login', 'admin.User/login');
//图片上传
Route::post('/union/upload', 'admin.Upload/index');
Route::group('', $func)->middleware(app\common\middleware\TokenCheck::class)->allowCrossDomain()->completeMatch(true);
